package com.ea.eadp.nexus.test.pageDefinition.newconsole;

import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.testng.Assert;


public class OriginAccountPage extends ConsoleBasePage {
    public static final String emailInputBox = "email";

    public OriginAccountPage(WebDriver driver) {
        super(driver, OriginAccountPage.class, emailInputBox);
    }

    public void enterEmail(String email) {
        log.info("Enter Email:" + email);
        sendInput(emailInputBox, email);
        clickBlank("//div[@id='panel-email']//span[@class='title']");
        sendControllerKey(Keys.UP);
        sendControllerKey(Keys.DOWN);
        sendControllerKey('A');
    }

    public void validateEmail(String email, String errorMessage) {
        log.info("Validate Email:" + email);
        sendInput(emailInputBox, email);
        clickBlank("//div[@id='panel-email']//span[@class='title']");
        Assert.assertEquals(getEmailInvalidError(), errorMessage, "Input not trigger the correct error message");
    }

    public String getTitle() {
        return getElementStringByXPath("//div[@id='panel-email']//span[@class='title']");
    }

    public String getDescription() {
        return getElementStringByXPath("//div[@id='panel-email']//p[@class='description']");
    }

    public String getEmailLabel() {
        return getElementStringByXPath("//li[@id='email-container']//label[@class='origin-ux-textbox-label']");
    }

    public String getEmailTip() {
        return getElementStringByXPath("//li[@id='email-container']//span[@class='origin-ux-tooltip-message-large']");
    }

    public String getEmailInvalidError() {
        return getElementStringByXPath("//li[@id='email-container']//span[@class='origin-ux-textbox-status-message origin-ux-status-message']");
    }
}

